Intro to R

Nick Dylla

7/30/2019

Purpose

  1. Expose you to a programming language (R)
  2. Demonstrate why you might want to use R
  3. Show you how to download and install…R
  4. Display some R examples
  5. Provide useful R resources
  1. A step-by-step tutorial on how to use R
  2. To convince everyone R is the language for them

About me

What is R?

The good and bad of Excel

  1. It’s ease of use
  2. Data entry
  3. Manipulating small amounts of data that can fit into one screen

  1. Handling large amounts of data
  2. Automating analyses
  3. Transparency (of analyses)
  4. High-quality graphics
  5. Version control (Can overwrite the only copy of a file)
  6. Reproducibility

What exactly does Reproducibility mean?

In data analysis, reproducibility usually means building a Reproducible environment

You can’t spell reproducible without R

  1. Handling large amounts of data
  2. Automating analyses
  3. Transparency (of analyses)
  4. High-quality graphics
    1. Extremely customizable (size, resolution, filetype, etc.)
  5. Version control (R makes any imported file an object and does not overwrite)
  6. Handling diverse file types
  7. Analysis Checkpoints (Allows users to put tests in place to identify errors)
  8. Highly Reproducible
  9. Creating Reports and Presentations (Like this one!)

Will I really ever need to learn R?

  1. Facebook
  2. Google
  3. Twitter
  4. Microsoft
  5. Uber

But who cares about big tech using R, how will it help me as an aspiring scientist?

Packages? What packages?

Where to download R

Download RStudio (Integrated Development Environment)

This is all great and I’m loving it, but what can R actually do?

R Example: Variable Assignment and Arithmetic

## [1] 12

R Example: Importing Excel File

excel_data <- readxl::read_xlsx("excel_example.xlsx")
head(excel_data) # show the first 6 rows
## # A tibble: 6 x 7
##   `First Name` `Last Name` Gender Country         Age Date          Id
##   <chr>        <chr>       <chr>  <chr>         <dbl> <chr>      <dbl>
## 1 Dulce        Abril       Female United States    32 15/10/2017  1562
## 2 Mara         Hashimoto   Female Great Britain    25 16/08/2016  1582
## 3 Philip       Gent        Male   France           36 21/05/2015  2587
## 4 Kathleen     Hanner      Female United States    25 15/10/2017  3549
## 5 Nereida      Magwood     Female United States    58 16/08/2016  2468
## 6 Gaston       Brumm       Male   United States    24 21/05/2015  2554

R Example: Map of Study Sites from Thesis

-Thesis link: https://harvest.usask.ca/bitstream/handle/10388/11889/DYLLA-THESIS-2019.pdf?sequence=1&isAllowed=y

R Example: Interactive Population Map of USA

R Example: Interactive 3D Bubble Plot of Life Expectancy vs GDP vs Population